<?
if (($c = stack('name')) && ($g = (int)param('gallery'))) {

	$s = array_extend( array('path' => 'album', 'w' => 800, 'h' => 600, 'tnw' => 128, 'tnh' => 96, 'imode' => MI_FIT, 'tnmode' => MI_FIT, 'gmode' => MI_FIT, 'gw' => 128, 'gh' => 96, 'gtpb' => 0, 'gparam' => 'gallery', 'param' => 'id', 'show_tn' => 1, 'nav' => 0, 'navigator' => 1, 'circular' => 0, 'autoscroll' => 0, 'fancybox' => 0, 'autogallery' => 0,), $DATA['components'][$c]['settings']);
	
	$s['path'] = $DATA['components'][$c]['settings']['path'] = FP_UPLOAD_PATH."$s[path]/$g";
	$DATA['components'][$c]['settings']['gtpb'] = (int)$s['gtpb'];

/*
	if (!sizeof($_tags = component_tags($c))) {
		$_tags = array('main' => 'gallery');
	}

	$DATA['components'][$c]['data'] = component_extract($c, -1, array('tags' => $_tags, 'gparam' => $g));

debug($DATA['components'][$c]['data']);
	
*/
	


	$t = datafetch_array('loadmeta', D_MB_META, array('parent' => $g, 'assoc' => context('lang'), 'getclob' => true));
	$DATA['components'][$c]['settings']['gallery-title'] = $t['title'];

	$DATA['components'][$c]['data'] = datafetch_array('gallery2', $s['path']);	// load existing images list
	
	if ($s['nav'] == 2)	// attach the fancybox css
		$META['style'][] = 'jquery.fancybox';

	unstack();
}